package com.heo.pojo;

import java.util.ArrayList;

import com.alibaba.fastjson.JSON;

public class CommandResult
{
  private String resultCode;
  private String resultMsg;
  private Integer signal;
  private ArrayList<ChannelInfo> channelInfoList = new ArrayList<ChannelInfo>();
  
  private Integer allDeviceNum = null;// 设备总数
  private Integer onlineDeviceNum = null;// 在线设备数
  private Integer busyDeviceNum = null;// 工作中的通道数量
  private Integer freeDeviceNum = null;// 空闲数量
  private Integer errorDeviceNum = null;// 错误数量
  private Integer lockedDeviceNum = null;// 锁定数量
  private Integer offlineDeviceNum = null;// 离线数量
  
  private DeviceInfoEntity deviceInfo = null;
  
  private String deviceResultList = null;//查询设备状态时，返回的设备列表，多个设备用逗号分割

  public CommandResult(String resultCode, String resultMsg)
  {
    this.resultCode = resultCode;
    this.resultMsg = resultMsg;
  }

  public CommandResult()
  {

  }

  public void addChanelInfo(Integer deviceChannelIndex,String deviceChannelStatus,String deviceChannelText,String callbackPara,String lockStatus,Long lockEndTime,String lockTocken,String errorCode,String errorText)
  {
    ChannelInfo channelInfo = new ChannelInfo();
    channelInfo.setDeviceChannelIndex(deviceChannelIndex);
    channelInfo.setDeviceChannelStatus(deviceChannelStatus);
    channelInfo.setDeviceChannelText(deviceChannelText);
    channelInfo.setLockStatus(lockStatus);
    channelInfo.setLockEndTime(lockEndTime);
    channelInfo.setLockTocken(lockTocken);
    channelInfo.setDeviceChannelErrorCode(errorCode);
    channelInfo.setDeviceChannelErrorText(errorText);

    if (callbackPara != null)
    {
      channelInfo.setCallbackPara(callbackPara);
    }
    channelInfoList.add(channelInfo);
  }

  public class ChannelInfo
  {
    private Integer deviceChannelIndex;
    private String deviceChannelStatus;
    private String deviceChannelErrorCode;
    private String deviceChannelErrorText;
    public String getDeviceChannelErrorCode() {
		return deviceChannelErrorCode;
	}

	public void setDeviceChannelErrorCode(String deviceChannelErrorCode) {
		this.deviceChannelErrorCode = deviceChannelErrorCode;
	}

	public String getDeviceChannelErrorText() {
		return deviceChannelErrorText;
	}

	public void setDeviceChannelErrorText(String deviceChannelErrorText) {
		this.deviceChannelErrorText = deviceChannelErrorText;
	}

	private String deviceChannelText;
    private String callbackPara = null;
    private String lockStatus = "UNLOCKED";
    private Long lockEndTime = null;//锁定结束时间
    private String lockTocken = null;//锁定的tocken

    public Integer getDeviceChannelIndex()
    {
      return deviceChannelIndex;
    }

    public void setDeviceChannelIndex(Integer deviceChannelIndex)
    {
      this.deviceChannelIndex = deviceChannelIndex;
    }

    public String getDeviceChannelStatus()
    {
      return deviceChannelStatus;
    }

    public void setDeviceChannelStatus(String deviceChannelStatus)
    {
      this.deviceChannelStatus = deviceChannelStatus;
    }

    public String getDeviceChannelText()
    {
      return deviceChannelText;
    }

    public void setDeviceChannelText(String deviceChannelText)
    {
      this.deviceChannelText = deviceChannelText;
    }

    public String getCallbackPara()
    {
      return callbackPara;
    }

    public void setCallbackPara(String callbackPara)
    {
      this.callbackPara = callbackPara;
    }

    public Long getLockEndTime()
    {
      return lockEndTime;
    }

    public void setLockEndTime(Long lockEndTime)
    {
      this.lockEndTime = lockEndTime;
    }

    public String getLockStatus()
    {
      return lockStatus;
    }

    public void setLockStatus(String lockStatus)
    {
      this.lockStatus = lockStatus;
    }

    public String getLockTocken()
    {
      return lockTocken;
    }

    public void setLockTocken(String lockTocken)
    {
      this.lockTocken = lockTocken;
    }
  }

  @Override
  public String toString()
  {
    return JSON.toJSONString(this);
  }

  public String getResultCode()
  {
    return resultCode;
  }

  public void setResultCode(String resultCode)
  {
    this.resultCode = resultCode;
  }

  public String getResultMsg()
  {
    return resultMsg;
  }

  public void setResultMsg(String resultMsg)
  {
    this.resultMsg = resultMsg;
  }

  public static class PublicResultCode
  {
    /**
     * 操作成功
     */
    public static final String SUCCESS = "SUCCESS";
    /**
     * 设备不存在
     */
    public static final String DEVICE_IS_NOT_EXIST = "DEVICE_IS_NOT_EXIST";
    /**
     * 设备的通道不存在
     */
    public static final String DEVICE_CHANNEL_INDEX_NOT_EXIST = "DEVICE_CHANNEL_INDEX_NOT_EXIST";
    /**
     * 设备不在线
     */
    public static final String DEVICE_IS_OFFLINE = "DEVICE_IS_OFFLINE";
    /**
     * 设备锁定中
     */
    public static final String DEVICE_CHANNEL_IS_LOCKING = "DEVICE_CHANNEL_IS_LOCKING";
    /**
     * 设备的通道不支持被锁定
     */
    public static final String DEVICE_CHANNEL_LOCK_IS_UNSUPPORTED = "DEVICE_CHANNEL_LOCK_IS_UNSUPPORTED";
    /**
     * 鉴权错误
     */
    public static final String AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR";
    /**
     * 参数错误
     */
    public static final String PARA_ERROR = "PARA_ERROR";
    /**
     * lockTocken不能为null
     */
    public static final String LOCK_TOCKEN_IS_NULL = "LOCK_TOCKEN_IS_NULL";   
    /**
     * 数据库操作错误
     */
    public static final String DB_ERROR = "DB_ERROR";
    /**
     * redis记录的数据错误
     */
    public static final String REDIS_LOGIC_ERROR = "REDIS_LOGIC_ERROR";
    /**
     * 未知错误
     */
    public static final String UNKNOW_ERROR = "UNKNOW_ERROR";
  }

  public static class PublicResultMsg
  {
    /**
     * 操作成功
     */
    public static final String SUCCESS = "操作成功";
    /**
     * 设备不存在
     */
    public static final String DEVICE_IS_NOT_EXIST = "设备不存在";
    /**
     * 设备不存在
     */
    public static final String DEVICE_CHANNEL_INDEX_NOT_EXIST = "设备的通道号不存在";
    /**
     * 设备不在线
     */
    public static final String DEVICE_IS_OFFLINE = "设备已离线";
    /**
     * 设备锁定中
     */
    public static final String DEVICE_CHANNEL_IS_LOCKING = "设备的通道锁定中";
    /**
     * 设备的通道不支持被锁定
     */
    public static final String DEVICE_CHANNEL_LOCK_IS_UNSUPPORTED = "设备的通道不支持被锁定";
    /**
     * 鉴权错误
     */
    public static final String AUTHENTICATION_ERROR = "鉴权错误";
    /**
     * 参数错误
     */
    public static final String PARA_ERROR = "参数错误";
    /**
     * lockTocken不能为null
     */
    public static final String LOCK_TOCKEN_IS_NULL = "lockTocken参数不能为null";   
    /**
     * 数据库操作错误
     */
    public static final String DB_ERROR = "数据库操作错误";
    /**
     * 未知错误
     */
    public static final String UNKNOW_ERROR = "未知错误";
    /**
     * redis记录的数据错误
     */
    public static final String REDIS_LOGIC_ERROR = "redis记录的数据逻辑错误";
  }

  /**
   * 启动设备结果
   */
  public static class StartDeviceResultCode
  {

  }

  public static class StartDeviceResultMsg
  {

  }

  /**
   * 查询状态结果
   */
  public static class QueryDeviceResultCode
  {
    /**
     * 操作成功
     */
    public static final String SUCCESS = "SUCCESS";

    public static final String DEVICE_CHANNEL_ERROR = "DEVICE_CHANNEL_ERROR";
    
    public static final String DEVICE_CHANNEL_INDEX_NOT_EXIST = "DEVICE_CHANNEL_INDEX_NOT_EXIST";

    public static final String DEVICE_ERROR = "DEVICE_ERROR";

    public static final String FREE = "FREE";

    public static final String START_SUCCESS = "START_SUCCESS";

    public static final String WORK_DONE = "WORK_DONE";

    public static final String WORKING = "WORKING";
    
    public static final String BUSY = "BUSY";
    
    public static final String LOCKED = "LOCKED";

  }

  public static class QueryDeviceResultMsg
  {
    /**
     * 操作成功
     */
    public static final String SUCCESS = "操作成功";

    public static final String DEVICE_CHANNEL_ERROR = "设备通道故障";
    
    public static final String DEVICE_CHANNEL_INDEX_NOT_EXIST = "设备通道编号不存在，或查询不到通道状态";

    public static final String DEVICE_ERROR = "设备故障";

    public static final String FREE = "设备空闲中";

    public static final String START_SUCCESS = "设备启动成功";

    public static final String WORK_DONE = "设备工作结束";

    public static final String WORKING = "设备工作中";
    
    public static final String BUSY = "设备繁忙";
    
    public static final String LOCKED = "设备已被预约";

  }

  public ArrayList<ChannelInfo> getChannelInfoList()
  {
    return channelInfoList;
  }

  public void setChannelInfoList(ArrayList<ChannelInfo> channelInfoList)
  {
    this.channelInfoList = channelInfoList;
  }

  public Integer getSignal()
  {
    return signal;
  }

  public void setSignal(Integer signal)
  {
    this.signal = signal;
  }

  public Integer getAllDeviceNum()
  {
    return allDeviceNum;
  }

  public void setAllDeviceNum(Integer allDeviceNum)
  {
    this.allDeviceNum = allDeviceNum;
  }

  public Integer getOnlineDeviceNum()
  {
    return onlineDeviceNum;
  }

  public void setOnlineDeviceNum(Integer onlineDeviceNum)
  {
    this.onlineDeviceNum = onlineDeviceNum;
  }

  public Integer getBusyDeviceNum()
  {
    return busyDeviceNum;
  }

  public void setBusyDeviceNum(Integer busyDeviceNum)
  {
    this.busyDeviceNum = busyDeviceNum;
  }

  public Integer getFreeDeviceNum()
  {
    return freeDeviceNum;
  }

  public void setFreeDeviceNum(Integer freeDeviceNum)
  {
    this.freeDeviceNum = freeDeviceNum;
  }

  public Integer getErrorDeviceNum()
  {
    return errorDeviceNum;
  }

  public void setErrorDeviceNum(Integer errorDeviceNum)
  {
    this.errorDeviceNum = errorDeviceNum;
  }

  public Integer getLockedDeviceNum()
  {
    return lockedDeviceNum;
  }

  public void setLockedDeviceNum(Integer lockedDeviceNum)
  {
    this.lockedDeviceNum = lockedDeviceNum;
  }

  public Integer getOfflineDeviceNum()
  {
    return offlineDeviceNum;
  }

  public void setOfflineDeviceNum(Integer offlineDeviceNum)
  {
    this.offlineDeviceNum = offlineDeviceNum;
  }

  public String getDeviceResultList()
  {
    return deviceResultList;
  }

  public void setDeviceResultList(String deviceResultList)
  {
    this.deviceResultList = deviceResultList;
  }

  public DeviceInfoEntity getDeviceInfo()
  {
    return deviceInfo;
  }

  public void setDeviceInfo(DeviceInfoEntity deviceInfo)
  {
    this.deviceInfo = deviceInfo;
  }
}
